package com.ecarx.engineermode.tab.model;

import androidx.fragment.app.Fragment;

public class ChildItem {
    String itemName;
    Class<?> fragmentARouter;
    Fragment fragment;

    public ChildItem(String itemName, Class<?> fragmentARouter) {
        this.itemName = itemName;
        this.fragmentARouter = fragmentARouter;
    }

    public Fragment getFragment() {
        if (fragment == null) {
            try {
                fragment = (Fragment) fragmentARouter.newInstance();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return fragment;
    }

    public String getItemName() {
        return itemName;
    }
}